package com.ts;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AndroidActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		System.out.println("FirstActivity--------------------onCreate");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		//        TextView myTextView01 = (TextView)findViewById(R.id.myTextView01);
		//        String str_2 = "欢迎来到android的TextView世界 http://www.hao123.com";
		//        myTextView01.setText(str_2);
		String strTextView01 = "TextView01";
		String strTextView02 = "TextVIew02";
		String strTextView03 = "TextView03";
		String strEditText01 = "EditText01";
		String strEditText02 = "EditText02";

		TextView myTextView01 = (TextView) findViewById(R.id.myTextView01);
		TextView myTextView02 = (TextView) findViewById(R.id.myTextView02);
		TextView myTextView03 = (TextView) findViewById(R.id.myTextView03);
		EditText myEditText01 = (EditText) findViewById(R.id.myEditText01);
		EditText myEditText02 = (EditText) findViewById(R.id.myEditText02);
		Button myButton = (Button) findViewById(R.id.myButton01);
		myTextView01.setText(strTextView01);
		myTextView02.setText(strTextView02);
		myTextView03.setText(strTextView03);
		myEditText01.setText(strEditText01);
		myEditText02.setText(strEditText02);
		String str01 = myEditText01.getText().toString();
		String str02 = myEditText02.getText().toString();

		//		myEditText01.
		myButton.setText("确定");
		myButton.setOnClickListener(new MyButronListener(this, str01, str02));
	}

	protected void onStart() {
		System.out.println("FirstAcivity ------------- onstart");
		super.onStart();
	}

	protected void onRestart() {
		System.out.println("FirstAcivity ------------- onRestart");
		super.onRestart();
	}

	protected void onResume() {
		System.out.println("FirstAcivity ------------- onResume");
		super.onRestart();
	}

	protected void onPause() {
		System.out.println("FirstAcivity ------------- onPause");
		super.onPause();
	}

	protected void onStop() {
		System.out.println("FirstAcivity ------------- onStop");
		super.onStop();
	}

	protected void onDestroy() {
		System.out.println("FirstAcivity ------------- onDestroy");
		super.onDestroy();
	}

	class MyButronListener implements OnClickListener {

		private AndroidActivity parentActivity;
		private String str01;
		private String str02;

		public MyButronListener(AndroidActivity activity, String str01, String str02) {
			this.parentActivity = activity;
			this.str01 = str01;
			this.str02 = str02;
		}

		@Override
		public void onClick(View v) {
			Intent intent = new Intent();
			intent.putExtra("showStr", "这是一个从" + AndroidActivity.this + "传递过来的参数" + str01 + "  " + str02);
			intent.setClass(AndroidActivity.this, AdditionActivity.class);
			intent.putExtra("showStr2", "这是一个从" + parentActivity + "传递过来的参数2");
			AndroidActivity.this.startActivity(intent);
		}
	}
}